package com.example.onion.hxchat.room.dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.example.onion.hxchat.room.entity.Message;
import com.example.onion.hxchat.room.entity.User;

import java.util.List;

/**
 * Message消息的Dao
 * @author:onion
 * @data: 2020/7/8
 */
@Dao
public interface MessageDao {
    @Insert
    void insertUser(Message... users);

    @Delete
    void deleteMessage(Message user);

    @Update
    void updateMessage(Message user);

    /**
     * 获得id和id1的聊天记录
     * @return all data of table Team
     */
    @Query("select * from Message where (userId = :id11 and toUserId = :id12 ) or (userId =:id21 and toUserId=:id22)")
    /**
     * 获得id1 和 id 的对话记录
     */
    LiveData<List<Message>> getAllMessageCur(String id11,String id12,String id21,String id22);

}
